//
//  HZZFMacro.h
//
//  Created by 早范 on 2025/7/13.
//  
//

#ifndef HZZFMacro_h
#define HZZFMacro_h

#define HZZF_SUPPRESS_PERFORM_SELECTOR_LEAK_WARNING(code) \
    _Pragma("clang diagnostic push") \
    _Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
    code; \
    _Pragma("clang diagnostic pop")

#ifndef HZZF_dispatch_main_async_safe
#define HZZF_dispatch_main_async_safe(block)    \
    if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(dispatch_get_main_queue())) == 0) { \
        block();    \
    } else {    \
        dispatch_async(dispatch_get_main_queue(), block);   \
    }
#endif


#define kHZZFStringIsEmpty(str) ([str isKindOfClass:[NSNull class]] || str == nil || ![str isKindOfClass:[NSString class]] || [str length] < 1 ? YES : NO)
#define kHZZFArrayIsEmpty(array) (array == nil || [array isKindOfClass:[NSNull class]] || ![array isKindOfClass:[NSArray class]] || array.count == 0)
#define kHZZFDictIsEmpty(dict) (dict == nil || [dict isKindOfClass:[NSNull class]] || ![dict isKindOfClass:[NSDictionary class]] || dict.allKeys.count == 0)
#define kHZZFObjectIsEmpty(_object) (_object == nil \
|| [_object isKindOfClass:[NSNull class]] \
|| ([_object respondsToSelector:@selector(length)] && [(NSData *)_object length] == 0) \
|| ([_object respondsToSelector:@selector(count)] && [(NSArray *)_object count] == 0))

// 机型UI适配宏
#define kHZZFIPhoneX (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && (kHZZFScreenWidth == 375.0 && kHZZFScreenHeight == 812.0))
#define kHZZFIphoneXS (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && (kHZZFScreenWidth == 375.0 && kHZZFScreenHeight == 812.0))
#define kHZZFIphoneXR (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && (kHZZFScreenWidth == 414.0 && kHZZFScreenHeight == 896.0) && (kScreenScale == 2))
#define kHZZFIphoneXS_MAX (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && (kHZZFScreenWidth == 414.0 && kHZZFScreenHeight == 896.0) && (kScreenScale == 3))
#define kHZZFCurveScreen (CGSizeEqualToSize(CGSizeMake(375.f, 812.f), [UIScreen mainScreen].bounds.size) \
|| CGSizeEqualToSize(CGSizeMake(812.f, 375.f), [UIScreen mainScreen].bounds.size) \
|| CGSizeEqualToSize(CGSizeMake(414.f, 896.f), [UIScreen mainScreen].bounds.size) \
|| CGSizeEqualToSize(CGSizeMake(896.f, 414.f), [UIScreen mainScreen].bounds.size) \
|| CGSizeEqualToSize(CGSizeMake(844.f, 390.f), [UIScreen mainScreen].bounds.size) \
|| CGSizeEqualToSize(CGSizeMake(812.f, 375.f), [UIScreen mainScreen].bounds.size) \
|| CGSizeEqualToSize(CGSizeMake(844.f, 390.f), [UIScreen mainScreen].bounds.size) \
|| CGSizeEqualToSize(CGSizeMake(926.f, 428.f), [UIScreen mainScreen].bounds.size) \
|| CGSizeEqualToSize(CGSizeMake(375.f, 812.f), [UIScreen mainScreen].bounds.size) \
|| CGSizeEqualToSize(CGSizeMake(390.f, 844.f), [UIScreen mainScreen].bounds.size) \
|| CGSizeEqualToSize(CGSizeMake(428.f, 926.f), [UIScreen mainScreen].bounds.size)) // 刘海屏幕

#define kHZZFStatusBarHeight (kHZZFCurveScreen ? 44 : 20)
#define kHZZFNavBarHeight ([UIDevice currentDevice].HZZF_isPad ? 50 : 44)
#define kHZZFTopBarHeight (kHZZFStatusBarHeight + kHZZFNavBarHeight)
#define kHZZFTabBarHeight (kHZZFCurveScreen ? 83 : 49)
#define kHZZFBottomSafeHeight (kHZZFStatusBarHeight>20?34:0)

#endif /* HZZFMacro_h */
